from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse
from notifications.models import Notification

# Create your views here.


def my_notifications_center(request):
    return render(request, 'my_notification_center.html')


def notification(request, notification_pk):
    notification_obj = get_object_or_404(Notification, pk=notification_pk)
    if notification_obj.unread:
        # 修改消息状态为已读
        notification_obj.unread = 0
        notification_obj.save()
    return render(request, 'notification.html', {'notification': notification_obj})